<template>
    <el-main class="main-container">
        <!-- 头部区域 -->
        <div class="header-wrapper">
            <div class="page-title">
                <h1>餐品管理</h1>
                <p>管理您的餐品库存和信息</p>
            </div>

            <div class="user-profile">
                <el-dropdown trigger="hover" @command="handleDropdownCommand">
                    <div class="avatar-wrapper">
                        <el-badge :value="notificationCount" :max="99" :hidden="!notificationCount">
                            <el-avatar class="user-avatar" :src="$store.state.user.headPicture"
                                @error="handleAvatarError">
                                <i class="el-icon-user-solid"></i>
                            </el-avatar>
                        </el-badge>
                        <div class="user-info">
                            <span class="user-name">{{ $store.state.user.name || '管理员' }}</span>
                            <span class="user-role">系统管理员</span>
                        </div>
                        <i class="el-icon-arrow-down dropdown-icon"></i>
                    </div>
                    <el-dropdown-menu slot="dropdown" class="custom-dropdown">
                        <el-dropdown-item command="profile" icon="el-icon-user">个人资料</el-dropdown-item>
                        <el-dropdown-item command="upload" icon="el-icon-camera">更换头像</el-dropdown-item>
                        <el-dropdown-item command="settings" icon="el-icon-setting">系统设置</el-dropdown-item>
                        <el-dropdown-item divided command="logout" icon="el-icon-switch-button">退出登录</el-dropdown-item>
                    </el-dropdown-menu>
                </el-dropdown>
            </div>
        </div>

        <!-- 统计卡片区域 -->
        <div class="stats-section">
            <div class="stat-card">
                <div class="stat-icon total">
                    <i class="el-icon-s-goods"></i>
                </div>
                <div class="stat-content">
                    <div class="stat-value">{{ total }}</div>
                    <div class="stat-label">总餐品数</div>
                </div>
            </div>
            <div class="stat-card">
                <div class="stat-icon active">
                    <i class="el-icon-check"></i>
                </div>
                <div class="stat-content">
                    <div class="stat-value">{{ activeGoodsCount }}</div>
                    <div class="stat-label">已启用</div>
                </div>
            </div>
            <div class="stat-card">
                <div class="stat-icon inactive">
                    <i class="el-icon-close"></i>
                </div>
                <div class="stat-content">
                    <div class="stat-value">{{ inactiveGoodsCount }}</div>
                    <div class="stat-label">已禁用</div>
                </div>
            </div>
            <div class="stat-card">
                <div class="stat-icon low-stock">
                    <i class="el-icon-warning"></i>
                </div>
                <div class="stat-content">
                    <div class="stat-value">{{ lowStockCount }}</div>
                    <div class="stat-label">库存不足</div>
                </div>
            </div>
        </div>

        <!-- 搜索和操作区域 -->
        <div class="action-section">
            <div class="search-filters">
                <el-input v-model="filters.name" placeholder="搜索餐品名称..." clearable class="search-input"
                    @clear="handleSearch" @keyup.enter="handleSearch">
                    <i slot="prefix" class="el-input__icon el-icon-search"></i>
                </el-input>

                <el-select v-model="filters.type" placeholder="选择类型" clearable class="filter-select">
                    <el-option label="全部类型" value=""></el-option>
                    <el-option label="主食" value="main"></el-option>
                    <el-option label="小食" value="snack"></el-option>
                    <el-option label="饮品" value="drink"></el-option>
                    <el-option label="甜品" value="dessert"></el-option>
                </el-select>

                <el-select v-model="filters.status" placeholder="选择状态" clearable class="filter-select">
                    <el-option label="全部状态" value=""></el-option>
                    <el-option label="已启用" :value="0"></el-option>
                    <el-option label="已禁用" :value="1"></el-option>
                </el-select>

                <el-button type="primary" icon="el-icon-search" @click="handleSearch" :loading="listLoading">
                    搜索
                </el-button>
                <el-button icon="el-icon-refresh" @click="handleRefresh">重置</el-button>
            </div>

            <div class="action-buttons">
                <el-button type="success" icon="el-icon-plus" @click="handleAdd" class="add-btn">
                    添加餐品
                </el-button>
                <el-button type="danger" icon="el-icon-delete" :disabled="multipleSelection.length === 0"
                    @click="handleBatchDelete" class="batch-delete-btn">
                    批量删除 ({{ multipleSelection.length }})
                </el-button>
                <el-button type="info" icon="el-icon-download" @click="handleExport">
                    导出数据
                </el-button>
            </div>
        </div>

        <!-- 表格区域 -->
        <div class="table-section">
            <el-table v-loading="listLoading" :data="paginatedData" @selection-change="handleSelectionChange"
                class="custom-table" stripe :row-class-name="tableRowClassName" :header-cell-style="headerCellStyle"
                empty-text="暂无数据" element-loading-text="加载中...">

                <el-table-column type="selection" width="55" align="center" />

                <el-table-column prop="id" label="ID" width="80" align="center">
                    <template slot-scope="{ row }">
                        <el-tag size="mini" type="info">#{{ row.id }}</el-tag>
                    </template>
                </el-table-column>

                <el-table-column prop="image" label="图片" width="100" align="center">
                    <template slot-scope="{ row }">
                        <el-image :src="row.image || '/placeholder-food.jpg'" class="goods-image" fit="cover"
                            :preview-src-list="[row.image || '/placeholder-food.jpg']">
                            <div slot="error" class="image-slot">
                                <i class="el-icon-picture-outline"></i>
                            </div>
                        </el-image>
                    </template>
                </el-table-column>

                <el-table-column prop="name" label="餐品名称" min-width="200" show-overflow-tooltip>
                    <template slot-scope="{ row }">
                        <div class="goods-name-cell">
                            <span class="goods-name">{{ row.name }}</span>
                            <el-tag v-if="row.isNew" size="mini" type="success">新品</el-tag>
                            <el-tag v-if="row.isHot" size="mini" type="danger">热销</el-tag>
                        </div>
                    </template>
                </el-table-column>

                <el-table-column prop="type" label="类型" width="120" align="center">
                    <template slot-scope="{ row }">
                        <el-tag :type="getTypeColor(row.type)" size="small">{{ getTypeText(row.type) }}</el-tag>
                    </template>
                </el-table-column>

                <el-table-column prop="price" label="价格" width="100" align="center">
                    <template slot-scope="{ row }">
                        <span class="price-text">¥{{ row.price || '0.00' }}</span>
                    </template>
                </el-table-column>

                <el-table-column prop="sort" label="库存" width="120" align="center">
                    <template slot-scope="{ row }">
                        <span :class="getStockClass(row.sort)">{{ row.sort || 0 }}</span>
                    </template>
                </el-table-column>

                <el-table-column prop="status" label="状态" width="100" align="center">
                    <template slot-scope="{ row }">
                        <el-switch v-model="row.status" :active-value="0" :inactive-value="1" active-color="#13ce66"
                            inactive-color="#ff4949" @change="handleStatusChange(row.id, row.status)">
                        </el-switch>
                    </template>
                </el-table-column>

                <el-table-column prop="createTime" label="创建时间" width="160" align="center">
                    <template slot-scope="{ row }">
                        <span>{{ formatDate(row.createTime) }}</span>
                    </template>
                </el-table-column>

                <el-table-column label="操作" width="200" fixed="right" align="center">
                    <template slot-scope="{ row }">
                        <div class="action-buttons-cell">
                            <el-tooltip content="查看详情" placement="top">
                                <el-button size="mini" type="info" icon="el-icon-view" circle
                                    @click="handleView(row)"></el-button>
                            </el-tooltip>
                            <el-tooltip content="编辑" placement="top">
                                <el-button size="mini" type="primary" icon="el-icon-edit" circle
                                    @click="handleEdit(row.id)"></el-button>
                            </el-tooltip>
                            <el-tooltip content="删除" placement="top">
                                <el-button size="mini" type="danger" icon="el-icon-delete" circle
                                    @click="handleDelete(row.id)"></el-button>
                            </el-tooltip>
                        </div>
                    </template>
                </el-table-column>
            </el-table>
        </div>

        <!-- 分页区域 -->
        <div class="pagination-section">
            <div class="pagination-info">
                <span>共 {{ total }} 条记录，每页显示 {{ pageSize }} 条</span>
            </div>
            <el-pagination :current-page.sync="currentPage" :page-sizes="[10, 20, 50, 100]" :page-size.sync="pageSize"
                :total="total" layout="sizes, prev, pager, next, jumper" @size-change="handleSizeChange"
                @current-change="handlePageChange" background :pager-count="5" />
        </div>

        <!-- 头像上传 -->
        <input type="file" ref="fileInput" @change="handleFileChange" style="display: none" accept="image/*" />

        <!-- 餐品详情弹窗 -->
        <el-dialog title="餐品详情" :visible.sync="detailDialogVisible" width="600px" :before-close="closeDetailDialog">
            <div v-if="currentGoods" class="goods-detail">
                <div class="detail-header">
                    <el-image :src="currentGoods.image || '/placeholder-food.jpg'" class="detail-image" fit="cover">
                        <div slot="error" class="image-slot">
                            <i class="el-icon-picture-outline"></i>
                        </div>
                    </el-image>
                    <div class="detail-info">
                        <h3>{{ currentGoods.name }}</h3>
                        <p class="detail-price">¥{{ currentGoods.price || '0.00' }}</p>
                        <el-tag :type="getStatusType(currentGoods.status)">{{ getStatusText(currentGoods.status)
                            }}</el-tag>
                    </div>
                </div>
                <el-divider></el-divider>
                <div class="detail-content">
                    <el-row :gutter="20">
                        <el-col :span="12">
                            <p><strong>类型：</strong>{{ getTypeText(currentGoods.type) }}</p>
                            <p><strong>库存：</strong>{{ currentGoods.sort || 0 }}</p>
                        </el-col>
                        <el-col :span="12">
                            <p><strong>创建时间：</strong>{{ formatDate(currentGoods.createTime) }}</p>
                            <p><strong>更新时间：</strong>{{ formatDate(currentGoods.updateTime) }}</p>
                        </el-col>
                    </el-row>
                    <div v-if="currentGoods.description" class="goods-description">
                        <p><strong>描述：</strong></p>
                        <p>{{ currentGoods.description }}</p>
                    </div>
                </div>
            </div>
            <span slot="footer" class="dialog-footer">
                <el-button @click="detailDialogVisible = false">关闭</el-button>
                <el-button type="primary" @click="handleEdit(currentGoods.id)">编辑</el-button>
            </span>
        </el-dialog>
    </el-main>
</template>

<script>
import { getGoodsList, deleteGoods, updateStatus } from '@/api/admin/Goods'
import { getUserList } from '@/api/admin/User'

export default {
    name: 'GoodsManagement',
    data() {
        return {
            currentPage: 1,
            pageSize: 10,
            total: 0,
            filters: {
                name: '',
                type: '',
                status: ''
            },
            listLoading: false,
            tableData: [],
            multipleSelection: [],
            detailDialogVisible: false,
            currentGoods: null,
            notificationCount: 3
        }
    },
    computed: {
        paginatedData() {
            return this.tableData.slice((this.currentPage - 1) * this.pageSize, this.currentPage * this.pageSize)
        },
        activeGoodsCount() {
            return this.tableData.filter(item => item.status === 0).length
        },
        inactiveGoodsCount() {
            return this.tableData.filter(item => item.status === 1).length
        },
        lowStockCount() {
            return this.tableData.filter(item => (item.sort || 0) < 10).length
        },
        headerCellStyle() {
            return {
                background: 'linear-gradient(135deg, #667eea 0%, #764ba2 100%)',
                color: '#fff',
                fontWeight: '600',
                fontSize: '14px'
            }
        }
    },
    methods: {
        // 格式化日期
        formatDate(date) {
            if (!date) return '-'
            return new Date(date).toLocaleString('zh-CN')
        },

        // 获取类型颜色
        getTypeColor(type) {
            const colorMap = {
                'main': '',
                'snack': 'success',
                'drink': 'warning',
                'dessert': 'danger'
            }
            return colorMap[type] || 'info'
        },

        // 获取类型文本
        getTypeText(type) {
            const textMap = {
                'main': '主食',
                'snack': '小食',
                'drink': '饮品',
                'dessert': '甜品'
            }
            return textMap[type] || '未知'
        },

        // 获取库存样式类
        getStockClass(stock) {
            const count = stock || 0
            if (count === 0) return 'stock-empty'
            if (count < 10) return 'stock-low'
            if (count < 50) return 'stock-medium'
            return 'stock-high'
        },

        // 获取状态文本
        getStatusText(status) {
            return status === 1 ? '已禁用' : '已启用'
        },

        // 获取状态类型
        getStatusType(status) {
            return status === 1 ? 'danger' : 'success'
        },

        // 表格行类名
        tableRowClassName({ rowIndex }) {
            return rowIndex % 2 === 1 ? 'striped-row' : ''
        },

        // 选择改变
        handleSelectionChange(selection) {
            this.multipleSelection = selection
        },

        // 页码改变
        async handlePageChange(newPage) {
            this.currentPage = newPage
            await this.loadData()
        },

        // 每页大小改变
        async handleSizeChange(newSize) {
            this.pageSize = newSize
            this.currentPage = 1
            await this.loadData()
        },

        // 搜索
        async handleSearch() {
            this.currentPage = 1
            await this.loadData()
        },

        // 重置
        async handleRefresh() {
            this.filters = {
                name: '',
                type: '',
                status: ''
            }
            this.currentPage = 1
            await this.loadData()
        },

        // 添加餐品
        handleAdd() {
            this.$router.push('/home/addGoods')
        },

        // 编辑餐品
        handleEdit(id) {
            this.$router.push(`/home/UPGoods/${id}`)
        },

        // 查看详情
        handleView(row) {
            this.currentGoods = row
            this.detailDialogVisible = true
        },

        // 关闭详情弹窗
        closeDetailDialog() {
            this.detailDialogVisible = false
            this.currentGoods = null
        },

        // 批量删除
        async handleBatchDelete() {
            if (this.multipleSelection.length === 0) {
                this.$message.warning('请选择要删除的餐品')
                return
            }

            try {
                await this.$confirm(
                    `确定删除选中的 ${this.multipleSelection.length} 个餐品吗？此操作不可恢复！`,
                    '批量删除确认',
                    {
                        type: 'warning',
                        confirmButtonText: '确定删除',
                        cancelButtonText: '取消'
                    }
                )

                const ids = this.multipleSelection.map(item => item.id)
                await deleteGoods(ids)
                await this.loadData()
                this.$message.success(`成功删除 ${this.multipleSelection.length} 个餐品`)
                this.multipleSelection = []
            } catch (error) {
                if (error !== 'cancel') {
                    this.$message.error('删除失败，请重试')
                }
            }
        },

        // 删除单个
        async handleDelete(id) {
            try {
                await this.$confirm('确定删除该餐品吗？此操作不可恢复！', '删除确认', {
                    type: 'warning',
                    confirmButtonText: '确定删除',
                    cancelButtonText: '取消'
                })

                await deleteGoods([id])
                await this.loadData()
                this.$message.success('删除成功')
            } catch (error) {
                if (error !== 'cancel') {
                    this.$message.error('删除失败，请重试')
                }
            }
        },

        // 状态切换
        async handleStatusChange(id, status) {
            try {
                await updateStatus({ id, status })
                this.$message.success('状态更新成功')
                // 不需要重新加载数据，因为已经通过 v-model 更新了
            } catch (error) {
                // 如果更新失败，恢复原来的状态
                const item = this.tableData.find(item => item.id === id)
                if (item) {
                    item.status = status === 0 ? 1 : 0
                }
                this.$message.error('状态更新失败')
            }
        },

        // 导出数据
        handleExport() {
            this.$message.info('导出功能开发中...')
        },

        // 下拉菜单命令
        handleDropdownCommand(command) {
            switch (command) {
                case 'profile':
                    this.$message.info('个人资料功能开发中...')
                    break
                case 'upload':
                    this.triggerFileUpload()
                    break
                case 'settings':
                    this.$message.info('系统设置功能开发中...')
                    break
                case 'logout':
                    this.handleLogout()
                    break
            }
        },

        // 退出登录
        async handleLogout() {
            try {
                await this.$confirm('确定要退出登录吗？', '退出确认', { type: 'warning' })
                this.$store.dispatch('user/logout')
                this.$router.push('/login')
            } catch (error) {
                // 取消操作
            }
        },

        // 头像错误处理
        handleAvatarError() {
            this.$store.commit('user/UPDATE_AVATAR', '/default-avatar.png')
        },

        // 触发文件上传
        triggerFileUpload() {
            this.$refs.fileInput.click()
        },

        // 文件改变处理
        async handleFileChange(e) {
            const file = e.target.files[0]
            if (!file) return

            const isJPG = file.type === 'image/jpeg' || file.type === 'image/png'
            const isLt2M = file.size / 1024 / 1024 < 2

            if (!isJPG) {
                this.$message.error('上传头像图片只能是 JPG/PNG 格式!')
                return
            }
            if (!isLt2M) {
                this.$message.error('上传头像图片大小不能超过 2MB!')
                return
            }

            try {
                this.listLoading = true
                const formData = new FormData()
                formData.append('file', file)
                // const response = await uploadAvatar(formData)
                // 模拟上传成功
                const response = { code: 1, data: URL.createObjectURL(file) }

                if (response.code === 1) {
                    this.$store.commit('user/UPDATE_AVATAR', response.data)
                    this.$message.success('头像更新成功')
                } else {
                    this.$message.error('头像更新失败')
                }
            } catch (error) {
                this.$message.error('上传失败，请重试')
            } finally {
                this.listLoading = false
                this.$refs.fileInput.value = ''
            }
        },

        // 加载数据
        async loadData() {
            this.listLoading = true
            try {
                const params = {
                    page: this.currentPage,
                    pageSize: this.pageSize,
                    ...this.filters
                }

                // 使用模拟数据
                await new Promise(resolve => setTimeout(resolve, 800)) // 模拟网络延迟

                const mockData = {
                    data: {
                        records: [
                            { id: 1, name: '麻辣香锅', type: 'main', price: 32.00, sort: 15, status: 0, image: '/food1.jpg', createTime: '2024-01-15 10:30:00', isHot: true },
                            { id: 2, name: '珍珠奶茶', type: 'drink', price: 15.00, sort: 5, status: 0, image: '/food2.jpg', createTime: '2024-01-16 14:20:00', isNew: true },
                            { id: 3, name: '炸鸡腿', type: 'snack', price: 18.00, sort: 0, status: 1, image: '/food3.jpg', createTime: '2024-01-17 16:45:00' },
                            { id: 4, name: '芒果布丁', type: 'dessert', price: 12.00, sort: 25, status: 0, image: '/food4.jpg', createTime: '2024-01-18 09:15:00' },
                            { id: 5, name: '宫保鸡丁', type: 'main', price: 28.00, sort: 8, status: 0, image: '/food5.jpg', createTime: '2024-01-19 11:30:00' },
                        ],
                        total: 5
                    }
                }

                this.tableData = mockData.data.records
                this.total = mockData.data.total
            } catch (error) {
                this.$message.error('数据加载失败，请刷新重试')
            } finally {
                this.listLoading = false
            }
        }
    },

    mounted() {
        this.loadData()
    }
}
</script>

<style lang="less" scoped>
.main-container {
    padding: 24px;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    min-height: calc(100vh - 60px);

    // 头部区域
    .header-wrapper {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 24px;
        background: #fff;
        padding: 20px 24px;
        border-radius: 16px;
        box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);

        .page-title {
            h1 {
                margin: 0 0 8px 0;
                font-size: 28px;
                font-weight: 700;
                background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
                -webkit-background-clip: text;
                -webkit-text-fill-color: transparent;
            }

            p {
                margin: 0;
                color: #8590a6;
                font-size: 14px;
            }
        }

        .user-profile {
            .avatar-wrapper {
                display: flex;
                align-items: center;
                gap: 12px;
                cursor: pointer;
                padding: 8px 16px;
                border-radius: 12px;
                transition: all 0.3s ease;

                &:hover {
                    background: rgba(102, 126, 234, 0.1);
                }

                .user-avatar {
                    width: 48px;
                    height: 48px;
                    border: 3px solid #667eea;
                    transition: transform 0.3s ease;
                }

                .user-info {
                    display: flex;
                    flex-direction: column;

                    .user-name {
                        font-size: 16px;
                        font-weight: 600;
                        color: #2d3748;
                    }

                    .user-role {
                        font-size: 12px;
                        color: #8590a6;
                    }
                }

                .dropdown-icon {
                    color: #8590a6;
                    transition: transform 0.3s ease;
                }

                &:hover .dropdown-icon {
                    transform: rotate(180deg);
                }
            }
        }
    }

    // 统计卡片区域
    .stats-section {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
        gap: 20px;
        margin-bottom: 24px;

        .stat-card {
            background: #fff;
            padding: 24px;
            border-radius: 16px;
            box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
            display: flex;
            align-items: center;
            gap: 16px;
            transition: all 0.3s ease;

            &:hover {
                transform: translateY(-4px);
                box-shadow: 0 12px 48px rgba(0, 0, 0, 0.15);
            }

            .stat-icon {
                width: 60px;
                height: 60px;
                border-radius: 16px;
                display: flex;
                align-items: center;
                justify-content: center;
                font-size: 24px;
                color: #fff;

                &.total {
                    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
                }

                &.active {
                    background: linear-gradient(135deg, #56ab2f 0%, #a8e6cf 100%);
                }

                &.inactive {
                    background: linear-gradient(135deg, #ff416c 0%, #ff4b2b 100%);
                }

                &.low-stock {
                    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
                }
            }

            .stat-content {
                flex: 1;

                .stat-value {
                    font-size: 32px;
                    font-weight: 700;
                    color: #2d3748;
                    line-height: 1;
                    margin-bottom: 4px;
                }

                .stat-label {
                    font-size: 14px;
                    color: #8590a6;
                    font-weight: 500;
                }
            }
        }
    }

    // 操作区域
    .action-section {
        background: #fff;
        padding: 24px;
        border-radius: 16px;
        box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
        margin-bottom: 24px;
        display: flex;
        justify-content: space-between;
        align-items: flex-end;
        flex-wrap: wrap;
        gap: 16px;

        .search-filters {
            display: flex;
            gap: 12px;
            flex-wrap: wrap;
            align-items: center;

            .search-input {
                width: 280px;
            }

            .filter-select {
                width: 140px;
            }
        }

        .action-buttons {
            display: flex;
            gap: 12px;
            flex-wrap: wrap;

            .add-btn {
                background: linear-gradient(135deg, #56ab2f 0%, #a8e6cf 100%);
                border: none;
                color: #fff;
                font-weight: 600;

                &:hover {
                    background: linear-gradient(135deg, #4a9628 0%, #96d9bb 100%);
                }
            }

            .batch-delete-btn {
                background: linear-gradient(135deg, #ff416c 0%, #ff4b2b 100%);
                border: none;
                color: #fff;
                font-weight: 600;

                &:hover:not(:disabled) {
                    background: linear-gradient(135deg, #e63946 0%, #e63946 100%);
                }

                &:disabled {
                    opacity: 0.5;
                    cursor: not-allowed;
                }
            }
        }
    }

    // 表格区域
    .table-section {
        background: #fff;
        border-radius: 16px;
        box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
        overflow: hidden;
        margin-bottom: 24px;

        .custom-table {
            border-radius: 16px;

            &.el-table--striped .striped-row {
                background: rgba(102, 126, 234, 0.05);
            }

            .goods-image {
                width: 60px;
                height: 60px;
                border-radius: 8px;
                object-fit: cover;
                cursor: pointer;

                .image-slot {
                    display: flex;
                    justify-content: center;
                    align-items: center;
                    width: 100%;
                    height: 100%;
                    background: #f5f7fa;
                    color: #909399;
                    font-size: 20px;
                }
            }

            .goods-name-cell {
                display: flex;
                align-items: center;
                gap: 8px;
                flex-wrap: wrap;

                .goods-name {
                    font-weight: 600;
                    color: #2d3748;
                }
            }

            .price-text {
                font-weight: 700;
                color: #e53e3e;
                font-size: 16px;
            }

            .stock-empty {
                color: #e53e3e;
                font-weight: 700;
            }

            .stock-low {
                color: #dd6b20;
                font-weight: 600;
            }

            .stock-medium {
                color: #38a169;
                font-weight: 500;
            }

            .stock-high {
                color: #319795;
                font-weight: 500;
            }

            .action-buttons-cell {
                display: flex;
                gap: 8px;
                justify-content: center;
            }
        }
    }

    // 分页区域
    .pagination-section {
        background: #fff;
        padding: 20px 24px;
        border-radius: 16px;
        box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
        display: flex;
        justify-content: space-between;
        align-items: center;

        .pagination-info {
            color: #8590a6;
            font-size: 14px;
        }
    }

    // 餐品详情弹窗
    .goods-detail {
        .detail-header {
            display: flex;
            gap: 20px;
            margin-bottom: 20px;

            .detail-image {
                width: 120px;
                height: 120px;
                border-radius: 12px;
                flex-shrink: 0;

                .image-slot {
                    display: flex;
                    justify-content: center;
                    align-items: center;
                    width: 100%;
                    height: 100%;
                    background: #f5f7fa;
                    color: #909399;
                    font-size: 24px;
                    border-radius: 12px;
                }
            }

            .detail-info {
                flex: 1;

                h3 {
                    margin: 0 0 12px 0;
                    font-size: 24px;
                    font-weight: 700;
                    color: #2d3748;
                }

                .detail-price {
                    font-size: 28px;
                    font-weight: 700;
                    color: #e53e3e;
                    margin: 0 0 16px 0;
                }
            }
        }

        .detail-content {
            p {
                margin: 8px 0;
                line-height: 1.6;

                strong {
                    color: #2d3748;
                    font-weight: 600;
                }
            }

            .goods-description {
                margin-top: 20px;
                padding-top: 20px;
                border-top: 1px solid #e2e8f0;

                p:last-child {
                    background: #f7fafc;
                    padding: 16px;
                    border-radius: 8px;
                    margin: 12px 0 0 0;
                    color: #4a5568;
                    line-height: 1.6;
                }
            }
        }
    }
}

// 自定义下拉菜单样式
:deep(.custom-dropdown) {
    border-radius: 12px;
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.15);

    .el-dropdown-menu__item {
        padding: 12px 20px;
        font-size: 14px;

        &:hover {
            background: rgba(102, 126, 234, 0.1);
            color: #667eea;
        }

        &.is-divided {
            border-top: 1px solid #e2e8f0;
        }
    }
}

// 响应式设计
@media (max-width: 768px) {
    .main-container {
        padding: 16px;

        .header-wrapper {
            flex-direction: column;
            gap: 16px;
            text-align: center;

            .page-title h1 {
                font-size: 24px;
            }
        }

        .stats-section {
            grid-template-columns: repeat(2, 1fr);
        }

        .action-section {
            flex-direction: column;
            align-items: stretch;

            .search-filters {
                flex-direction: column;

                .search-input,
                .filter-select {
                    width: 100%;
                }
            }

            .action-buttons {
                justify-content: center;

                .el-button {
                    flex: 1;
                    min-width: 120px;
                }
            }
        }

        .table-section {
            overflow-x: auto;

            .custom-table {
                min-width: 800px;
            }
        }

        .pagination-section {
            flex-direction: column;
            gap: 16px;
            text-align: center;
        }
    }
}

@media (max-width: 480px) {
    .main-container {
        .stats-section {
            grid-template-columns: 1fr;
        }

        .action-buttons {
            flex-direction: column;

            .el-button {
                width: 100%;
            }
        }
    }
}

// 动画效果
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.main-container>* {
    animation: fadeInUp 0.6s ease-out;
}

.main-container>*:nth-child(1) {
    animation-delay: 0.1s;
}

.main-container>*:nth-child(2) {
    animation-delay: 0.2s;
}

.main-container>*:nth-child(3) {
    animation-delay: 0.3s;
}

.main-container>*:nth-child(4) {
    animation-delay: 0.4s;
}

.main-container>*:nth-child(5) {
    animation-delay: 0.5s;
}
</style>